using System;
using System.Collections.Generic;
using System.Text;

namespace Sedna.Core.Persistence.Hql
{
    public class HqlFromClause
    {
        private IList<HqlFromToken> list = new List<HqlFromToken>();

        public bool IsEmpty
        {
            get { return list.Count == 0; }
        }
        
        public HqlFromToken Add(string entity)
        {
            HqlFromToken token = new HqlFromToken(this, entity);
            list.Add(token);
            return token;
        }

        public void Build(StringBuilder sb)
        {
            sb.Append(" from ");
            foreach (HqlFromToken token in list)
            {
                sb.Append(token.ToString()).Append(',');
            }
            sb.Remove(sb.Length - 1, 1);
        }
    }
}
